/*
 * @Description: 维修派工接口
 * @Autor: 何兴家
 * @Date: 2020-10-27 14:24:51
 * @LastEditors: 何兴家
 * @LastEditTime: 2021-03-16 13:29:37
 */

import axios from '@/api/fetch';
import SERVER from '@/api/server';

// 查询派工信息
export const queryRepairAssign = params =>
  axios.get(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/queryRepairAssignNoPage`, {
    params
  });

export const getAllUserByWorkGroupId = params =>
  axios.get(`/api/sysManage/basedata/users/getAllUserByWorkGroupId`, {
    params
  });

// 获取上一次预约服务顾问
export const getLastServiceAdvisor = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/getServiceAdvisor`, { params });

// 查询漆辅料
export const queryRo = id => axios.get(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/queryRo/${id}`, {});
// 保存漆辅料
export const maintainRoRepairPart = params => axios.put(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/maintainRoRepairPartByFl`, params);
// 整单派工
export const maintainRepairAssignComplete = params => axios.put(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/maintainRepair`, params);
// 取消竣工
export const maintainRepairBack = id => axios.put(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/maintainRepairBack/${id}`, {});
// 根据工单号查询维修项目
export const queryRoLabourByRoNOss = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/queryRoLabourByRoNOess`, { params });
// 根据工单号查询维修项目
export const queryRoLabourByRoNOs = roNo => axios.get(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/queryRoLabourByRoNOs/${roNo}`, {});
// 根据工单号查询维修项目
export const queryRoAssignByRoNO = roNo => axios.get(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/queryRoAssignByRoNO/${roNo}`, {});
// 根据工单号查询备件
export const queryRoRepairPartByTag = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/queryRoRepairPartByTag`, { params });
// 更新等待答复
export const updateRepairAssignTag = (roNo, waitTag) => axios.put(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/UpdateRepairAssignTag/${roNo}/${waitTag}`, {});
// 更新等待备件
export const updateRepairAssignPartTag = (roNo, waitPartTag) => axios.put(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/UpdateRepairAssignPartTag/${roNo}/${waitPartTag}`, {});
// 查询是否有可派工的维修项目
export const queryRepair = id => axios.get(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/queryRepair/${id}`, {});
// 查询辅料备件
export const queryStockInfo = params =>
  axios.get(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/queryStockInfo`, {
    params
  });
// 查询派工
export const queryRoAssignByRoNOs = id => axios.get(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/queryRoAssignByRoNOs/${id}`, {});
// 查询所有班组
export const getWorkAllGroup = id => axios.get(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/getWorkAllGroup`, {});
// 新增派工保存
export const saveAssign = params => axios.put(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/saveAssign`, params);
// 查询技师
export const queryTechnicians = id => axios.get(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/queryTechnicians`, {});
// 分项派工删除
export const deleteAssign = params => axios.put(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/delete`, params);
// 查询實際工時
export const queryRoAssignItem = assignId => axios.get(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/queryRoAssignItem/${assignId}`, {});
// 完工保存
export const maintainComplish = params => axios.put(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/maintainComplish`, params);
// 查詢未入賬备件
export const queryFinished = id => axios.get(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/queryFinished/${id}`, {});
// 根據id查詢要求改的派工信息
export const queryR = id => axios.get(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/queryR/${id}`, {});
// 根據工单号、id查詢打印数据
export const queryPrintData = (roNo, id) => axios.get(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/queryTechnicianForRepairOrder/${roNo}/${id}`, {});
// 根據工单号查詢技师
export const queryTechnician = roNo => axios.get(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/queryTechnicianForRepairOrder/${roNo}`, {});

// 维修工位接口
export const selectWorkGroupDicts = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/maintainWorkType/dicts/select`, params);
// 主页面竣工校验不修项目
export const checkProject = roNo => axios.get(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/queryProject/${roNo}`, {});
// 选择维修项目时候查询派工单
export const queryRoAssign = id => axios.get(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/queryRoAssign/${id}`, {});
// 维修派工导出
export const roAssignExportExcel = params =>
  axios.get(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/roAssign/export/excel`, {
    params,
    responseType: 'arraybuffer'
  });
export const getDealerCompanyByCode = params =>
  axios.get(`${SERVER.DMSCLOUD_BASEDATA}/dealer/getDealerChannelByCode`, {
    params
  });
// 保存派工情况
export const saveRepairAssign = params => axios.post(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/saveRepairAssign`, params);

// 客制化新增
// 完工验收
export const maintainComplishNew = params => axios.post(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/maintainComplishNew`, params);

// 竣工
export const maintainRepairNew = params => axios.post(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/maintainRepairNew`, params);

// 取消竣工
export const maintainRepairBackNew = params => axios.post(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/maintainRepairBackNew`, params);

// 完工验收查询维修项目
export const queryRoLabourByRoNOsNoPage = roNo => axios.get(`${SERVER.DMSCLOUD_REPAIR}/repairAssign/queryRoLabourByRoNOsNoPage/${roNo}`, {});
